// Reference Counting Test (Fixed Version)
// Tests Rc<T> and Weak<T> functionality without nil comparisons

// Test structures
type TestStruct struct {
    value int
    name String
}

impl TestStruct {
    func init() {
        println("TestStruct created with value: ", self.value)
    }
    
    func drop() {
        println("TestStruct destroyed with value: ", self.value)
    }
}

func test_rc_suite() {
    println("=== Rc Test Suite (Fixed Version) ===")
    
    // Test 1: Basic Rc<int> operations
    println("--- Test 1: Basic Rc<int> ---")
    var rcInt Rc<int> = Rc<int>{42}
    println("Created Rc<int> with value: ", rcInt)
    
    // Test 2: Basic Rc<TestStruct> operations
    println("--- Test 2: Basic Rc<TestStruct> ---")
    var rcStruct Rc<TestStruct> = Rc<TestStruct>{value: 100, name: "test"}
    println("Created Rc<TestStruct> with value: ", rcStruct.value)
    
    // Test 3: Rc operations without nil comparisons
    println("--- Test 3: Rc Operations ---")
    var rc1 Rc<int> = Rc<int>{10}
    var rc2 Rc<int> = Rc<int>{20}
    println("Created rc1: ", rc1, " and rc2: ", rc2)
    
    // Test 4: Multiple Rc references
    println("--- Test 4: Multiple Rc References ---")
    var rc3 Rc<int> = Rc<int>{30}
    var rc4 Rc<int> = Rc<int>{rc3}
    println("Created rc3: ", rc3, " and rc4: ", rc4)
    
    // Test 5: Rc with struct
    println("--- Test 5: Rc with Struct ---")
    var rcStruct2 Rc<TestStruct> = Rc<TestStruct>{value: 200, name: "test2"}
    println("Created rcStruct2 with value: ", rcStruct2.value)
    
    println("=== All Rc tests completed (without nil comparisons) ===")
    println("Note: This test avoids nil comparisons to prevent segmentation faults")
}
